﻿<UserControl x:Class="TVersiPlay.MediaBrowse.Views.MediaBrowseView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:scroll="clr-namespace:TVersiPlay.Common.Controls;assembly=TVersiPlay.Common"
             xmlns:common="clr-namespace:TVersiPlay.Common;assembly=TVersiPlay.Common"
             xmlns:prism="http://www.codeplex.com/CompositeWPF"
             xmlns:igDock="http://infragistics.com/DockManager"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="600">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVisConverter" />

        <Style x:Key="ContainerListboxStyle" TargetType="{x:Type ItemsControl}">
            <!-- Set the ItemTemplate of the ListBox to a DataTemplate which
           explains how to display an object of type BitmapImage. -->
            <Setter Property="ItemTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Border VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="DarkGray" BorderThickness="2"
                                CornerRadius="5" Margin="5">
                            <Label Background="Black"  Width="120" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
                                <!--<i:Interaction.Triggers>
                                    <i:EventTrigger EventName="MouseDoubleClick">
                                        <ca:CommandAction  Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ItemsControl}}, Path=DataContext.BrowseContainer}"
                                                           CommandParameter="{Binding}"
                                        />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>-->
                                <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="100" />
                                        <RowDefinition Height="20" />
                                    </Grid.RowDefinitions>
                                    <Image Opacity=".2" Source="{Binding Path=ContainerIcon}" Stretch="Fill" />
                                    <Grid Grid.Row="0">
                                        <TextBlock Foreground="WhiteSmoke" FontSize="14" FontWeight="Heavy" HorizontalAlignment="Stretch" TextAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Text="{Binding Path=ContainerFriendlyName}"/>
                                    </Grid>
                                    <StackPanel Grid.Row="1" HorizontalAlignment="Stretch">
                                        <Button Width="20" Height="20"
                                                HorizontalAlignment="Right"
                                                HorizontalContentAlignment="Center" 
                                                VerticalContentAlignment="Center" 
                                                FontSize="16" Content="a" FontFamily="Webdings"  
                                                Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ItemsControl}}, Path=DataContext.BrowseContainer}"
                                                CommandParameter="{Binding}" />
                                    </StackPanel>
                                </Grid>
                            </Label>

                        </Border>

                    </DataTemplate>
                </Setter.Value>
            </Setter>

            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>

            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility"
                Value="Disabled"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility"
                Value="Disabled"/>
        </Style>       

    </UserControl.Resources>
    <Grid>
        <igDock:XamDockManager Theme="Office2k7Black" HorizontalAlignment="Stretch" Name="xamDockManager1" VerticalAlignment="Stretch" >
            <igDock:XamDockManager.Panes>
                <igDock:SplitPane igDock:XamDockManager.InitialLocation="DockedTop" MinHeight="100" > <!--Visibility="{Binding Path=HasContainerResults,Converter={StaticResource BoolToVisConverter}}">-->
                    <igDock:ContentPane Header="Navigation" Background="Black" IsPinned="{Binding Path=HasContainerResults}" AllowClose="False" AllowDocking="False" CloseButtonVisibility="Hidden" PinButtonVisibility="Visible" WindowPositionMenuVisibility="Hidden">
                        <scroll:DragScrollViewer VerticalAlignment="Stretch" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
                            <ItemsControl VerticalAlignment="Stretch" ItemsSource="{Binding Path=UPnPContainerResults}" Style="{StaticResource ContainerListboxStyle}"  />
                        </scroll:DragScrollViewer>
                    </igDock:ContentPane>
                </igDock:SplitPane>
            </igDock:XamDockManager.Panes>

            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <ContentControl Grid.Row="0" prism:RegionManager.RegionName="{x:Static common:RegionNames.BrowseResultsRegion}" />
            </Grid>

        </igDock:XamDockManager>
    </Grid>
</UserControl>
